$(document).ready(function () {
    //首行变色
    $("#MainTable tr:gt(2)").mouseover(function () {
        this.oldcolor = this.style.backgroundColor;
        this.style.backgroundColor = 'red';
    })
    .mouseout(function () {
        this.style.backgroundColor = this.oldcolor;
    });
    //自身变色
    $("#MainTable tr td:gt(3)").mouseover(function () {
        //this.oldcolor=this.style.backgroundColor;
        //this.style.backgroundColor='red';
    })
    .mouseout(function () {
        //this.style.backgroundColor=this.oldcolor;
    });
    //首列变色
    $("#MainTable tr td:gt(0)").mouseover(function () {
        var tdSeq = $(this).parent().find('> td').index($(this)[0]) - 1;
        if (tdSeq < 0) return;
        $("#MainTable tr:eq(2) td:eq(" + tdSeq + ")")[0].bgColor = $("#MainTable tr:eq(2) td:eq(" + tdSeq + ")")[0].style.backgroundColor;
        $("#MainTable tr:eq(2) td:eq(" + tdSeq + ")")[0].style.backgroundColor = 'red';
    })
     	.mouseout(function () {
     	    var tdSeq = $(this).parent().find('> td').index($(this)[0]) - 1;
     	    if (tdSeq < 0) return;
     	    $("#MainTable tr:eq(2) td:eq(" + tdSeq + ")")[0].style.backgroundColor = $("#MainTable tr:eq(2) td:eq(" + tdSeq + ")")[0].bgColor;
     	});

    var bSelect = false;
    $("#MainTable tr td:gt(3)").mousedown(function () {
        if ($("*").hasClass("selected")) $("*").removeClass("selected");
        //获得table的行号
        var dtrSeq = $(this).parent().parent().find('>tr').index($(this).parent()[0]) + 1;
        //获得table的列号
        var dtdSeq = $(this).parent().find('>td').index($(this)[0]) + 1;
        //获取会议室编号
        //var mtrName=$("td:first"); $(this).parent().find('tr'))


        //this.oldcolor = this.style.backgroundColor;
        $(this).addClass("selected");
        bSelect = true;
    });
    $("#MainTable tr td:gt(3)").mouseover(function () {
        if (bSelect) {
            //this.oldcolor = this.style.backgroundColor;
            $(this).addClass("selected");
        };
    });
    $("#MainTable tr td:gt(3)").mouseup(function () {
        bSelect = false;
        //gotoConfirm();
        //alert("弹出确认窗口，填写会议主题，参加人等信息");
    });


    $('#goNext').click(function () {
        var options = {
            type: "POST",
            url: "../Booking_chooseTime.asmx/GoNext",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            data: '{"startTime":"9:00","endTime":"11:00","mtrName":"2"}',
            success: function (response) {
                //alert("a");
                if (response != null) {
                    alert(response.d);                   
                }
            },
            error: function (result, status) { //如果没有上面的捕获出错会执行这里的回调函数
                alert(status);
                }
        };        
        $.ajax(options);
    });
});
 